home *** CD-ROM | disk | FTP | other *** search
- Path: news.kei.com!ub!newserve!rebecca!rpi!not-for-mail
- From: yossef@ird.scitex.com (Yossef Halakhmi)
- Newsgroups: comp.lang.c++.moderated,comp.lang.c++,comp.os.ms-windows.programmer.misc
- Subject: Re: STL loops through a list with one element more than once! Why?
- Date: 1 Jan 1996 17:47:33 -0000
- Organization: Scitex Corp.
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: Dietmar.Kuehl@uni-konstanz.de
- Message-ID: <4c96nl$1tr@netlab.cs.rpi.edu>
- References: <4c1n8o$2jn@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
-
- X-Original-Date: 31 Dec 1995 07:54:48 GMT
-
- In article <4c1n8o$2jn@netlab.cs.rpi.edu>, Bowden Wise <wiseb@cs.rpi.edu> wrote:
-
- > BOOL DDETopic::DelAllItems ()
- > {
- > for (_itemIter = _itemList.begin();
- > _itemIter != _itemList.end();
- > _itemIter++)
- > {
- > _itemList.erase (_itemIter);
- > }
- > return TRUE;
- > }
-
-
-
- After any one 'erase' your list is changed and iterator doesn't point to
- the objrct that you want . _itemList.end() also will point on something new.
- And not to the old value of _itemList.end() which you have in
- 'for' .
- If you want to erase all elements in list/array then use
- erase(iterator forst, iterator last) mem-function
-
- [ comp.lang.c++.moderated is a moderated newsgroup. Submit articles ]
- [ to <c++-submit@netlab.cs.rpi.edu>. The moderation policy can be ]
- [ retrieved from <http://netlab.cs.rpi.edu/~cppmods/guide.html>. ]
- [ Moderators can be reached at: c++-request@netlab.cs.rpi.edu. ]
-